package design_pattern.decorator.test1;

/**
 * 利用装饰者模式自由嵌套调用
 */
public class Test {
    public static void main(String[] args) {
        System.out.println("==== 组合1 ====");
        new Decorator2(new Decorator1(new ComponentIpml1())).dosomething();
        System.out.println();
        System.out.println("==== 组合2 ====");
        new Decorator1(new Decorator2(new ComponentIpml2())).dosomething();

       /*
        ==== 组合1 ====
        decorator 2 befor
        decorator 1 befor
        被装饰的类1：dosomething
        decorator 1 after
        decorator 2 after

        ==== 组合2 ====
        decorator 1 befor
        decorator 2 befor
        被装饰的类2：dosomething
        decorator 2 after
        decorator 1 after
        */
    }
}
